<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ATM取款机</title>
</head>

<body>
    <script>
        let money = 20000
        while (true) {
            let num = +prompt(`请输入数字，1为取钱，2为存钱，3为查看余额，4为退出银行卡`)
            if (num === 4) {
                alert('欢迎下次使用')
                break
            } else if (num === 1) {
                let num1 = +prompt('输入取出的金额')
                if (num1 > money) {
                    alert(`余额不足，请先存入足够的金额再来取钱`)
                } else {
                    money = money - num1
                    alert(`你取出了${num1}元，余额为：${money}`)
                }
            } else if (num === 2) {
                let num2 = +prompt('输入你存的金额')
                money = money + num2
                alert(`你存入了${num2}元,余额为：${money}`)
            } else if (num === 3) {
                alert(`你的余额为：${money}元`)
            } else {
                alert(`请输入1到4之间的整数`)
            }

        }
    </script>
</body>

</html>